#include "List.h"
#include<malloc.h>
void list_init(List* list)
{
	list->size = 0;
	list->front = list->tail = calloc(1, sizeof(Node));
	if (list->front == NULL)
	{
		printf("head create failed\n");
		return;
	}
}

Node* createNode(void* val)
{
	Node* newNode = calloc(1, sizeof(Node));
	if (!newNode)
	{
		printf("newNode create failed\n");
		return NULL;
	}
	newNode->data = val;
	return newNode;
}

void list_pushBack(List* list, void* val)
{
	Node* newNode = createNode(val);
	newNode->next = list->tail->next;
	list->tail->next = newNode;
	list->tail = newNode;
	list->size++;
}

void list_transfrom(List* list, LISTCALLBACK fun)
{
	Node* curNode = list->front->next;
	while (curNode)
	{
		fun(curNode->data);
		curNode = curNode->next;
	}
}
